/* $RCSFile: ViewItemImagePage.cs $
 * Apache license v2 2011 by Christian Surieux
 * $Source: ?/AddonNice.ImageSettings/UI/ViewItemImagePage.cs $
 * $log$
 * Revision 7 2010/08/09 09:44:02  christian.surieux
 *   Added Log to cs sources files
 */

using System;
using System.IO;
using System.Configuration;
using System.Collections;
using System.Reflection;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using AddonNice.UI;
using AddonNice.UI.WebControls;
using AddonNice.Security;
using AddonNice.Configuration;

using AddonNice.CRMImage;

namespace AddonNice.CRMImage.UI
{
	public class ViewItemImagePage : SecureImagePage
	{
		#region license

        private CRMImageManager _ImM;
        
        /// <summary>
        /// Check for ImageManager and AddonNice license
        /// </summary>
        protected override bool CheckLicense
        {
            get
            {
                if (_ImM == null)
                    _ImM = new CRMImageManager();
                if (_ImM != null)
                    return ( _ImM.License.IsValid && base.CheckLicense ) ;
                return false;
            }
        }

        /// Check for ImageManager AddonNice license demo mode
        public override bool IsDemo
        {
            get
            {
                if (_ImM == null)
                    _ImM = new CRMImageManager();
                if (_ImM != null)
                    return ( _ImM.DemoMode && base.IsDemo );
                return true;
            }
        }

        #endregion license

        /// <summary>
		/// Handles OnUpdate event
		/// </summary>
		protected override void OnUpdate(ADNPageEventArgs e) 
		{
			// Verify that the current user has access to add in this module
            if (!string.IsNullOrEmpty(EntityName) && !PortalSecurity.HasPropertiesPermissions(EntityName))
                PortalSecurity.AccessDeniedEdit();
			base.OnUpdate(e);
		}

        /// <summary>
        /// Load settings
        /// </summary>
        protected override void LoadSettings()
        {
            // Verify that the current user has access to view this module
            if (!string.IsNullOrEmpty(EntityName) && !PortalSecurity.HasViewPermissions(EntityName) ) 
                PortalSecurity.AccessDenied();
            base.LoadSettings();
        }
    }
}